<template>
  <view class="comment-form-container">

  </view>
</template>

<script>
export default {
  name: 'CommentForm',
  props: {
    // 控制弹窗显示
    value: {
      type: Boolean,
      default: false
    },
    // 订单ID
    orderId: {
      type: [String, Number],
      default: ''
    }
  },
  data() {
    return {
      formData: {
        efficiency: 5,  // 服务效率评分
        skill: 5,       // 服务技能评分
        attitude: 5,    // 服务态度评分
        content: ''     // 评价内容
      }
    };
  },
  computed: {
    show: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit('input', val);
      }
    }
  },
  watch: {
    // 当弹窗关闭时重置表单数据
    show(newVal) {
      if (!newVal) {
        this.resetForm();
      }
    }
  },
  methods: {
    // 重置表单
    resetForm() {
      this.formData = {
        efficiency: 5,
        skill: 5,
        attitude: 5,
        content: ''
      };
    },

    // 关闭弹窗
    onClose() {
      this.$emit('close');
    },

    // 取消按钮
    handleCancel() {
      this.show = false;
      this.$emit('cancel');
    },

    // 提交评价
    handleSubmit() {
      // 验证评价内容
      if (!this.formData.content.trim()) {
        this.$toast({ title: '请输入评价内容' });
        return;
      }

      // 发送评价数据
      this.$emit('submit', {
        order_id: this.orderId,
        ...this.formData
      });
    }
  }
};
</script>

<style lang="scss">
.comment-popup {
  padding: 40rpx;
  text-align: center;
  background-color: #ffffff;

  .popup-header {
    font-size: 38rpx;
    font-weight: bold;
    margin-bottom: 30rpx;
    color: #333333;
  }

  .comment-form {
    margin-bottom: 40rpx;

    .comment-item {
      margin-bottom: 30rpx;
      text-align: left;

      .comment-label {
        font-size: 28rpx;
        color: #333;
        margin-bottom: 20rpx;
      }

      .comment-textarea {
        width: 100%;
        height: 150rpx;
        padding: 20rpx;
        border: 1rpx solid #eee;
        border-radius: 10rpx;
        font-size: 26rpx;
        box-sizing: border-box;
      }
    }
  }

  .popup-footer {
    justify-content: space-between;

    .popup-btn {
      flex: 1;
      height: 70rpx;
      line-height: 70rpx;
      border-radius: 35rpx;
      margin: 0 20rpx;
      font-size: 28rpx;

      &.cancel-btn {
        background-color: #f2f4f8;
        color: #a6b0c6;
      }

      &.confirm-btn {
        background-color: #0066ff;
        color: #fff;
        border: none;
      }
    }
  }
}
</style>
